//
//  YBForeignListCollectionViewCell.m
//  GoodBuy
//
//  Created by dlios on 15-5-13.
//  Copyright (c) 2015年 GoodBuy. All rights reserved.
//

#import "YBForeignListCollectionViewCell.h"
#import "UIImageView+WebCache.h"

@interface YBForeignListCollectionViewCell ()



@end
@implementation YBForeignListCollectionViewCell

- (void)dealloc
{
    [_pic release];
    [_picture release];
    [_mall release];
    [_title release];
    [super dealloc];
}

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.picture = [[UIImageView alloc] init];
        _picture.layer.masksToBounds = YES;
        _picture.layer.cornerRadius = 30;
        _picture.contentMode = 2;
        [self.contentView addSubview:_picture];
        [_picture release];
        
        self.title = [[UILabel alloc] init];
        [self.contentView addSubview:_title];
        _title.numberOfLines = 0;
         [_title setFont:[UIFont systemFontOfSize:15]];
        [_title release];
        
        self.price = [[UILabel alloc] init];
        [self.contentView addSubview:_price];
         [_price setFont:[UIFont systemFontOfSize:15]];
        [_price setTextColor:[UIColor redColor]];
        _price.numberOfLines = 0;
//        _price.backgroundColor = [UIColor whiteColor];
//        [_price setShadowColor:[UIColor redColor]];
        [_price release];
        
        self.mall = [[UILabel alloc] init];
        [self.contentView addSubview:_mall];
//        _mall.backgroundColor = [UIColor redColor];
         [_mall setFont:[UIFont systemFontOfSize:15]];
        [_mall release];
        
        
      
    }
    return self;
}

-(void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    _picture.frame = CGRectMake(0, 0, self.contentView.bounds.size.width, self.contentView.bounds.size.height - 40);
    _title.frame =CGRectMake(0, _picture.frame.size.height, _picture.frame.size.width*1.3, 60);
    _price.frame = CGRectMake(0, _picture.frame.size.height + _title.frame.size.height, _title.frame.size.width, 40);
    _mall.frame = CGRectMake(0,_picture.frame.size.height + _title.frame.size.height +_price.frame.size.height , _title.frame.size.width, 40);
}

-(void)setPic:(YBForeignObject *)pic
{
    
    if (_pic != pic) {
        [_pic release];
        _pic = [pic retain];
    }
    
    [_picture sd_setImageWithURL:[NSURL URLWithString:pic.article_pic]placeholderImage:[UIImage imageNamed:@"zhanweitu"]];
    _title.text = pic.article_title;
    _price.text = pic.article_price;
    _mall.text = pic.article_mall;
 
    
}
@end
